package chapter07.chapter7_1_Move_Method.ver01;

/**
 * 账户类
 */
public class Account {

    private AccountType _type;

    /**
     * 透支的天数
     */
    private int _daysOverdrawn;

    /**
     * 透支费用
     *
     * @return
     */
    double overdraftCharge() {
        if (_type.isPremium()) {
            double result = 10;
            if (_daysOverdrawn > 7) {
                result += (_daysOverdrawn - 7) * 0.85;
            }
            return result;
        } else {
            return _daysOverdrawn * 1.75;
        }
    }

    /**
     * 给银行的费用：基本费用 + 透支费用
     * @return
     */
    double bankCharge() {
        double result = 4.5;
        if (_daysOverdrawn > 0) {
            result += overdraftCharge();
        }
        return result;
    }
}
